#include "gamecontroller.h"
GameController *GameController::gameController = nullptr;
GameController::GameController()
    :m_mainScene(nullptr)
    ,l_levelScene(nullptr)
    ,g_gameScene(nullptr)
{

}
GameController::~GameController(){

}

GameController *GameController::getInstance()
{
    if (gameController == nullptr){
        gameController = new GameController();

    }
    return gameController;
}




void GameController::initMainScene(MainScene *scene)
{
    m_mainScene = scene;
}

void GameController::showMainScene()
{
    if(m_mainScene != nullptr){
        m_mainScene->show();
    }
}

void GameController::hideMainScene()
{
    if(m_mainScene != nullptr){
        m_mainScene->hide();

    }
}

void GameController::showLevelScene()
{
    if(l_levelScene == nullptr){
        l_levelScene = new LevelScene();
    }
    l_levelScene->setGeometry(m_mainScene->geometry());
    l_levelScene->show();
}

void GameController::hideLevelScene()
{
    if(l_levelScene != nullptr){
        l_levelScene->hide();
    }
    m_mainScene->setGeometry(l_levelScene->geometry());
}

void GameController::showGameScene(int level)
{
    if(g_gameScene == nullptr){
        g_gameScene = new GameScene(level);
    }
    g_gameScene->setGeometry(l_levelScene->geometry());
    g_gameScene->show();
}

void GameController::hideGameScene()
{
    if(g_gameScene != nullptr){
        g_gameScene->hide();
    }
}

void GameController::deleteGameScene()
{
    if(g_gameScene != nullptr){
        l_levelScene->setGeometry(g_gameScene->geometry());
        delete g_gameScene;
    }
    g_gameScene = nullptr;
}

void GameController::playStartSound()
{
    QSound::play(SOUND_TAP_BUTTON);
}

void GameController::playBackSound()
{
    QSound::play(SOUND_BACK_BUTTON);
}

void GameController::playFlipCoinSound()
{
    QSound::play(SOUND_COIN_FLIP);
}

void GameController::playWinSound()
{
    QSound::play(SOUND_LEVEL_WIN);
}
